package com.xpffly.design.iterator.demo;

import com.xpffly.design.iterator.demo.service.IProject;
import com.xpffly.design.iterator.demo.service.IProjectIterator;
import com.xpffly.design.iterator.demo.service.impl.Project;

/**
 * @Author: xpengfei
 * @Date: 2021/4/13 20:37
 * @Description：迭代器模式demo场景类
 */
public class Scene {
    public static void main(String[] args) {
        // 定义一个List存放所有的项目对象
        IProject project = new Project();

        project.addProject("星球大战项目aaaa", 10, 100000);
        project.addProject("吃鸡", 36, 960000);
        project.addProject("王者荣耀", 23, 60000000);

        for (int i = 0; i < 5; i++) {
            project.addProject("第" + i + 4 + "个项目", (i + 1) * 3, (i + 1) * 90000);
        }
        // 遍历projectList 将所有的项目数据都取出来
        IProjectIterator projectIterator = project.iterator();
        while (projectIterator.hasNext()) {
            IProject project1 = (IProject) projectIterator.next();
            System.out.println(project1.getProjectInfo());
        }
    }
}
